package com.hrc.springbootdemo.async;

import jakarta.annotation.Resource;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;


import java.util.concurrent.CompletableFuture;

@Service
public class AsycService {
    @Resource
    private ApplicationContext applicationContext;
    @Async
    public CompletableFuture<String> async() {
        // AsycService bean = applicationContext.getBean(AsycService.class);
        // System.out.println("bean.async().join() = " + bean.async().join());
        System.out.println("asyn1c() = " + asyn1c().join());
        return CompletableFuture.completedFuture(Thread.currentThread().getName());
    }

    @Async
    public CompletableFuture<String> asyn1c() {
        return CompletableFuture.completedFuture(Thread.currentThread().getName());
    }

}
